var modTreeSample_locLang = new localLang("modTreeSample");
var modTreeSample;
modTreeSample = new Class({
    Extends:WFWindow,
    sampleProxyEnable:true,
    options:{
        name:'modTreeSample',
        title:modTreeSample_locLang.label('title'),
        btnSettings:true,
        btnRefresh:true,
        btnHelp:true,
        btnClose:true,
        loadCSS:true,
        supportServerTypes:['modSimple'],
        defaultWidgetHeight:244
    },
    renderContent:function () {
        this.pane = new Element('div', {'class':'pane-tree'}).inject(this.boxBD);
        this.tree = new Element('div', {'id':'myTree', 'class':'trend-tree'}).inject(this.pane);

        var CHILD = [],
                i;
        for (i = 0; i < 10; i++) {
            CHILD.push({
                NAME:" Root Domain << I N D E X >> " + i,
                GUID:i + '-'
            });
        }
        var root = {
            NAME:"OSCE server",
            GUID:'00000000-0000-0000-0000-000000000000',
            CHILD:CHILD
        };
        // prepare the cellsData
        function getSubDomain(GUID) {
            var DD = [],
                    i;
            for (i = 0; i < 20; i++) {
                DD.push({
                    NAME:" Sub Domain << I N D E X >> " + i,
                    GUID:GUID + i + '-'
                });
            }
            var d1 = {
                CHILD:DD
            };
            return d1;
        }

        (function ($) {
            $(function () {
                $('#myTree').trendTree({
                    data:root,
                    expand:function (ui) {
                        console.log('call expand');
                        if (ui.data.GUID == '10-') {
                            $('#myTree').trendTree('renderNode', ui, {
                                CHILD:[]
                            });
                        } else {
                            $('#myTree').trendTree('renderNode', ui, getSubDomain(ui.data.GUID));
                        }
                    },
                    selected:function (event, ui) {
                        console.log('call select');
                    }
                });
            });
        })(jQuery);
        window.fireEvent('widget_load', this.widgetInfo);
    },
    onClickRefresh2:function () {
    },
    displayChart:function () {
    },
    displaySuccess:function (response) {
    },
    displayFailure:function () {
    },
    onContentresize:function (event) {
    },
    refreshMod:function () {
    }
});
